import { type Directive } from "vue";
import { useAuthStore } from '@/stores/auth';

export const permissionDirectives: Directive = {
    mounted(el, binding) {
        const permissionStore = useAuthStore();
        const { value } = binding;

        if(value && !permissionStore.hasPermission(value)) {
            el.parentNode?.removeChild(el);
        }
    }
}